package com.apop.accompanyH5.home.service.impl;

import com.apop.accompanyH5.home.domain.entity.Hospital;
import com.apop.accompanyH5.home.mapper.HospitalMapper;
import com.apop.accompanyH5.home.service.HospitalService;
import com.apop.common.model.PageResult;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author JiayiZheng
 * @since 2024-10-07
 */
@Service
public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> implements HospitalService {

    @Override
    public Hospital getHospitalById(Integer id) {
        return baseMapper.selectById(id);
    }

    @Override
    public PageResult getHospitalList(Integer pageNo, Integer pageSize) {
        // 开启分页查询,当执行查询时，插件进行相关的sql拦截进行分页操作，返回一个page对象
        Page<Hospital> page = PageHelper.startPage(pageNo, pageSize);
        baseMapper.selectList(null);
        PageResult pageResult = new PageResult(page.getResult(), page.getTotal());
        return pageResult;
    }


}
